home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 92 / CDMM92_1.ISO / SOF 2 SDK / sof2sdk-101.msi / _92D6AC311BB48EBA344BBABC89DA6AB0 / _8AAF5EACFA40406790D6F9EBF2EA484C < prev    next >
Encoding:
Text File  |  2002-06-05  |  1.7 KB  |  90 lines

  1. // Copyright (C) 2001-2002 Raven Software.
  2. //
  3. // cg_light.c
  4.  
  5. #include "cg_local.h"
  6.  
  7. #if !defined(CG_LIGHTS_H_INC)
  8.     #include "cg_lights.h"
  9. #endif
  10.  
  11. static    clightstyle_t    cl_lightstyle[MAX_LIGHT_STYLES];
  12. static    int                lastofs;
  13.  
  14. /*
  15. ================
  16. FX_ClearLightStyles
  17. ================
  18. */
  19. void CG_ClearLightStyles (void)
  20. {
  21.     int    i;
  22.  
  23.     memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
  24.     lastofs = -1;
  25.  
  26.     for(i=0;i<MAX_LIGHT_STYLES*3;i++)
  27.     {
  28.         CG_SetLightstyle (i);
  29.     }
  30. }
  31.  
  32. /*
  33. ================
  34. FX_RunLightStyles
  35. ================
  36. */
  37. void CG_RunLightStyles (void)
  38. {
  39.     int        ofs;
  40.     int        i;
  41.     clightstyle_t    *ls;
  42.  
  43.     ofs = cg.time / 50;
  44. //    if (ofs == lastofs)
  45. //        return;
  46.     lastofs = ofs;
  47.  
  48.     for (i=0,ls=cl_lightstyle ; i<MAX_LIGHT_STYLES ; i++, ls++)
  49.     {
  50.         if (!ls->length)
  51.         {
  52.             ls->value[0] = ls->value[1] = ls->value[2] = ls->value[3] = 255;
  53.         }
  54.         else if (ls->length == 1)
  55.         {
  56.             ls->value[0] = ls->map[0][0];
  57.             ls->value[1] = ls->map[0][1];
  58.             ls->value[2] = ls->map[0][2];
  59.             ls->value[3] = 255; //ls->map[0][3];
  60.         }
  61.         else
  62.         {
  63.             ls->value[0] = ls->map[ofs%ls->length][0];
  64.             ls->value[1] = ls->map[ofs%ls->length][1];
  65.             ls->value[2] = ls->map[ofs%ls->length][2];
  66.             ls->value[3] = 255; //ls->map[ofs%ls->length][3];
  67.         }
  68.         trap_R_SetLightStyle(i, *(int*)ls->value);
  69.     }
  70. }
  71.  
  72. void CG_SetLightstyle (int i)
  73. {
  74.     const char    *s;
  75.     int            j, k;
  76.  
  77.     s = CG_ConfigString( i+CS_LIGHT_STYLES );
  78.     j = strlen (s);
  79.     if (j >= MAX_QPATH)
  80.     {
  81.         Com_Error (ERR_DROP, "svc_lightstyle length=%i", j);
  82.     }
  83.  
  84.     cl_lightstyle[(i/3)].length = j;
  85.     for (k=0 ; k<j ; k++)
  86.     {
  87.         cl_lightstyle[(i/3)].map[k][(i%3)] = (float)(s[k]-'a')/(float)('z'-'a') * 255.0;
  88.     }
  89. }
  90.